//
//  SKGreeterClient.m
//  Test
//
//  Created by 孙叔康 on 2022/7/28.
//

#define DATE_COMPONENTS (NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekOfMonth | NSCalendarUnitWeekOfYear | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond | NSCalendarUnitWeekday | NSCalendarUnitWeekdayOrdinal)

#define CURRENT_CALENDAR [NSCalendar currentCalendar]

#import "SKGreeterClient.h"

@implementation SKGreeterClient

- (instancetype)init{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (NSString *)greetingMessage{
    return [self greetingMessageWithDate:[NSDate date]];
}

-(NSString *)greetingMessageWithDate:(NSDate *)date{
    NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:date];
    NSInteger hour = components.hour;
    if (hour >= 6 && hour < 12) {
        return @"Good morning";
    } else if (hour >= 12 && hour < 18) {
        return @"Good afternoon";
    } else {
        return @"Good evening";
    }
}

@end
